package com.wonder.app.service.impl;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vtuzx.core.bean.dto.VtuzxMap;
import com.vtuzx.core.utils.VtuzxUtil;
import com.wonder.admin.domain.SysAdmin;
import com.wonder.admin.service.IVtuzxKingdeeService;
import com.wonder.app.domain.*;
import com.wonder.app.mapper.*;
import com.wonder.app.request.SfcProplanDetailRequest;
import com.wonder.app.request.SfcProplanRequest;
import com.wonder.app.service.*;
import com.wonder.bean.kingdee.VtuzxKingdeeCloudClient;
import com.wonder.bean.kingdee.xqc.VtuzxArrayList;
import com.wonder.common.common.AjaxResult;
import com.wonder.common.utils.DateUtils;
import com.wonder.common.utils.MessageUtils;
import com.wonder.common.utils.StringUtils;
import com.wonder.constant.BillType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class SfcProplanServiceImpl extends ServiceImpl<SfcProplanDao, SfcProplan> implements SfcProplanService {

    private static final Logger _logger = LoggerFactory.getLogger(ReceiveServiceImpl.class);
    @Autowired
    private SfcProplanDao sfcProplanpDao;

    @Autowired
    private SfcproplanDetailService sfcproplanDetailService;

    @Autowired
    private PrdFeedDetailDao prdFeedDetailDao;

    @Autowired
    private IVtuzxKingdeeService vtuzxKingdeeService;

    @Autowired
    private PrdInstockDao prdInstockDao;

    @Autowired
    private SfcProplanService sfcProplanpService;

    @Autowired
    private SfcproplanDetailDao sfcproplanDetailDao;

    @Autowired
    private SyncKingdeeOrderService syncKingdeeOrderService;

    @Autowired
    private PpBomService ppBomService;

    @Autowired
    private PpBomDao ppBomDao;

    @Autowired
    private PickDetailService pickDetailService;

    @Autowired
    private PickDetailDao pickDetailDao;

    @Autowired
    private MoldMaterialDao moldMaterialDao;

    @Autowired
    private PrdPickService prdPickService;

    @Autowired
    private SfcOptrptService sfcOptrptService;

    @Autowired
    private TrayDao trayDao;

    @Autowired
    private SfcOptrptDetailDao sfcOptrptDetailDao;

    @Autowired
    private SfcOptrptDao sfcOptrptDao;

    @Override
    public IPage<SfcProplan> selectList(SfcProplanRequest request, Page<SfcProplan> page) {
        LambdaQueryWrapper<SfcProplan> lambdaQueryWrapper = new LambdaQueryWrapper<>();

        if (request.getBillNo() != null){
            lambdaQueryWrapper.like(SfcProplan::getBillNo,request.getBillNo());
        }

        if (request.getDate() != null){
            Date[] orderDate = request.getDate();
            if(orderDate.length>0)
                lambdaQueryWrapper.ge(SfcProplan::getDate, orderDate[0]);
            if(orderDate.length==2)
                lambdaQueryWrapper.le(SfcProplan::getDate,orderDate[1]);

        }
        if (request.getSpecification() != null){
            lambdaQueryWrapper.like(SfcProplan::getSpecification,request.getSpecification());
        }

        if (null != request.getDepartNo()) {
            String departNo = request.getDepartNo().replace("'", "''"); // 防注入
            lambdaQueryWrapper.inSql(SfcProplan::getBillNo,
                    "SELECT BillNo FROM t_sfc_proplan_detail WHERE DepartNo = '" + departNo + "'");
        }
        lambdaQueryWrapper.orderByDesc(SfcProplan::getDate);
        Page<SfcProplan> selectPage = this.baseMapper.selectPage(page, lambdaQueryWrapper);
        List<SfcProplan> records = selectPage.getRecords();
        //返回的结果加上车间信息
        List<String> billNos = records.stream().map(SfcProplan::getBillNo).collect(Collectors.toList());

        if (!billNos.isEmpty()) {
            List<Map<String, Object>> departList = sfcproplanDetailDao.selectDepartNoMapByBillNos(billNos);

            // 转换成 Map<String, String>，key=BillNo, value=DepartNo
            Map<String, String> departMap = departList.stream()
                    .collect(Collectors.toMap(
                            m -> m.get("BillNo").toString(),
                            m -> m.get("DepartNo") != null ? m.get("DepartNo").toString() : "",
                            (oldValue, newValue) -> oldValue // 遇到重复 key 保留旧值

                    ));

            records.forEach(item -> {
                item.setDepartNo(departMap.get(item.getBillNo()));
            });
        }

        return selectPage;
    }

    /**
     * 审核工序计划单
     * @param map
     * @return
     * @throws Exception
     */
    @Override
    public boolean audit(JSONObject map) throws Exception {
        _logger.info("审核工序计划单"+ map.toString());
        JSONArray erceives = map.getJSONArray("Sfcproplan");
        JSONObject receiveObj = (JSONObject) erceives.get(0);
        JSONArray head = receiveObj.getJSONArray("model");//单据头数据
        JSONArray detailList = receiveObj.getJSONArray("detail");//单据体数据、
        JSONArray ppBoms = receiveObj.getJSONArray("ppbom");//bom
        List<SfcProplan> sfcProplanList = new ArrayList<>();
        List<SfcproplanDetail> sfcproplanDetailList = new ArrayList<>();
        List<PpBom> ppBomList = new ArrayList<>();
        List<Long> fidList = new ArrayList<>();//单据头需要删除的fid集合
        List<Long> entryIdList = new ArrayList<>();//单据体需要删除的entryid集合
        List<Long> bomIdList = new ArrayList<>();//单据体需要删除的entryid集合
        for (Object obj : head) {
            JSONObject jsonObject = (JSONObject) obj;
            //将json直接转成实体类
            SfcProplan sfcProplan =jsonObject.toBean(SfcProplan.class);
            sfcProplan.setMoldStatus(false);
            Long fid = sfcProplan.getFid();
            if (!fidList.contains(fid)){
                fidList.add(fid);
            }
            sfcProplanList.add(sfcProplan);
        }
        //单据体数据
        for (Object obj : detailList) {
            JSONObject jsonObject = (JSONObject) obj;
            //将json直接转成实体类
            SfcproplanDetail sfcproplanDetail = jsonObject.toBean(SfcproplanDetail.class);
//            sfcproplanDetail.setOperName(sfcproplanDetail.getProcessName());
            Long entryId = sfcproplanDetail.getFENTRYID();
            if (!entryIdList.contains(entryId)){
                entryIdList.add(entryId);
            }
            sfcproplanDetailList.add(sfcproplanDetail);
        }


        //bom数据
        for (Object obj : ppBoms) {
            JSONObject jsonObject = (JSONObject) obj;
            //将json直接转成实体类
            PpBom ppBom = jsonObject.toBean(PpBom.class);
            ppBom.setFRESIDUEQTY(ppBom.getFMUSTQTY());//剩余未发数量等于应发数量
            Long bomFid = ppBom.getFID();
            if (!bomIdList.contains(bomFid)){
                bomIdList.add(bomFid);
            }
            ppBomList.add(ppBom);
        }

        //查询有没有需要删除的单据
        List<SfcProplan> sfcdelete = sfcProplanpDao.selectList(new LambdaQueryWrapper<SfcProplan>()
                .in(SfcProplan::getFid,fidList));
        if (null != sfcdelete || sfcdelete.size() > 0){
            sfcProplanpDao.delete(new LambdaQueryWrapper<SfcProplan>()
                    .in(SfcProplan::getFid,fidList));
        }
        List<SfcproplanDetail> sfcproplanDetailList1 =  sfcproplanDetailDao.selectList(new LambdaQueryWrapper<SfcproplanDetail>()
                .in(SfcproplanDetail::getFENTRYID,entryIdList));
        if (null != sfcproplanDetailList1 || sfcproplanDetailList1.size() > 0){
            sfcproplanDetailDao.delete(new LambdaQueryWrapper<SfcproplanDetail>()
                    .in(SfcproplanDetail::getFENTRYID,entryIdList));

        }

        List<PpBom> ppBomList1 =  ppBomDao.selectList(new LambdaQueryWrapper<PpBom>()
                .in(PpBom::getFID,bomIdList));
        if (!VtuzxUtil.isEmpty(ppBomList1)  && ppBomList1.size() > 0){
            ppBomDao.delete(new LambdaQueryWrapper<PpBom>()
                    .in(PpBom::getFID,bomIdList));//根据工单删除

        }


        //向数据库添加数据
        boolean resHead = sfcProplanpService.saveOrUpdateBatch(sfcProplanList);
        boolean res = sfcproplanDetailService.saveOrUpdateBatch(sfcproplanDetailList);
        boolean bomres = ppBomService.saveOrUpdateBatch(ppBomList);
        return res && resHead;
    }

    /**
     * 获取工序计划单数据
     * @param billno
     * @return
     */
    public Map<String,Object> getRroPlan(String billno){
        SfcProplan sfcProplan = new SfcProplan();
        List<SfcproplanDetail> sfcproplanDetailList = new ArrayList<>();
        sfcProplan = sfcProplanpDao.selectOne(new LambdaQueryWrapper<SfcProplan>()
                .eq(SfcProplan::getBillNo,billno));
        sfcproplanDetailList = sfcproplanDetailDao.selectList(new LambdaQueryWrapper<SfcproplanDetail>()
                .eq(SfcproplanDetail::getBillNo,billno));
        Map<String,Object> data = new HashMap<>();
        data.put("data",sfcProplan);
        data.put("detail",sfcproplanDetailList);
        return data;

    }
    @Override
    public Map<String, Object> getSfcProPlanDetail(Map<String, Object> map) {
        String billNo = map.get("billNo").toString();
        SfcProplan sfcProplanform = sfcProplanpDao.selectOne(new LambdaQueryWrapper<SfcProplan>()
                .eq(SfcProplan::getBillNo,billNo));
        List<SfcproplanDetail> sfcProplandetailList = sfcproplanDetailDao.selectList(new LambdaQueryWrapper<SfcproplanDetail>()
                .eq(SfcproplanDetail::getBillNo,billNo));
        Map<String,Object> data = new HashMap<>();
        data.put("data",sfcProplanform);
        data.put("dataList",sfcProplandetailList);

        return data;
    }
   //"查询工序计划明细(手机端领料列表)"
    @Override
    public Map<String, Object> getPlanlist(SysAdmin user, Map<String, Object> map) {
        int pageIndex = VtuzxUtil.getInt(map,"pageIndex");
        int pageSize = VtuzxUtil.getInt(map,"pageSize");
        String billNo = VtuzxUtil.getString(map,"billNo");//订单号
        String produceStr = user.getProduceList();//车间信息
        List<String> produceNoList = new ArrayList<>();
        if (!VtuzxUtil.isEmpty(produceStr)){
            produceNoList = Arrays.asList(produceStr.split(","));
        }

        if (billNo.contains(",")){//说明是根据件号查询
            List<String> stringList = Arrays.asList(billNo.split(","));
            List<SfcProplan> dataList = sfcProplanpDao.getPlanlistByItem(pageSize,pageIndex * pageSize,stringList,produceNoList);
            Map<String,Object> data = new HashMap<>();
            data.put("dataList",dataList);
            return data;
        } else {
            List<SfcProplan> dataList = sfcProplanpDao.getPlanlist(pageSize,pageIndex * pageSize,billNo,produceNoList);
            Map<String,Object> data = new HashMap<>();
            data.put("dataList",dataList);
            return data;
        }

    }
    //"查询工序计划明细(手机端不领料列表)"
    @Override
    public Map<String, Object> getPlanisDetail(Map<String, Object> map) {
        String billNo = map.get("billNo").toString();
        String operNo = VtuzxUtil.getString(map,"operNo");
        SfcProplan sfcProplanform = sfcProplanpDao.selectOne(new LambdaQueryWrapper<SfcProplan>()
                .eq(SfcProplan::getBillNo,billNo));
        if(null == sfcProplanform){
            throw new RuntimeException("单号错误请重试");
        }
        List<SfcproplanDetail> sfcProplandetailList = sfcproplanDetailDao.selectList(new LambdaQueryWrapper<SfcproplanDetail>()
                .eq(SfcproplanDetail::getBillNo,billNo));
        //查询当前工单，工序汇报的总数量
        //先查询外层表，然后查询内层表汇总数量
        double reportCount = 0.0;
        List<SfcOptrpt> optrpts = sfcOptrptDao.selectList(new LambdaQueryWrapper<SfcOptrpt>()
                .eq(SfcOptrpt::getErpBillNo, billNo)
                .eq(SfcOptrpt::getOperpNo, operNo));

        if (!VtuzxUtil.isEmpty(optrpts)){
            List<String> billNoList = optrpts.stream()
                    .map(SfcOptrpt::getBillNo)
                    .filter(Objects::nonNull)
                    .collect(Collectors.toList());
            List<SfcOptrptDetail> sfcOptrptDetails = sfcOptrptDetailDao.selectList(new LambdaQueryWrapper<SfcOptrptDetail>()
                    .in(SfcOptrptDetail::getBillNo, billNoList));
            reportCount = sfcOptrptDetails.stream()
                    .mapToDouble(SfcOptrptDetail::getEndQty)
                    .sum();
        }


        Map<String,Object> data = new HashMap<>();
        data.put("data",sfcProplanform);
        data.put("dataList",sfcProplandetailList);
        data.put("reportCount",reportCount);

        return data;
    }

    /**
     * 获取工序计划详情(补料单)
     * @param map
     * @param user_id
     * @return
     * @throws Exception
     */
    @Override
    public Map<String, Object> getPlanDetailFeed(Map<String, Object> map, Long user_id) throws Exception {
        String billNo = map.get("billNo").toString();
        SfcProplan sfcProplan = sfcProplanpDao.selectOne(new LambdaQueryWrapper<SfcProplan>()
                .eq(SfcProplan::getBillNo,billNo));
        if(null == sfcProplan){
            throw new RuntimeException("单号错误请重试");
        }
        //详情数据展示补料中的临时数据信息
        List<PrdFeedDetail> detailList = prdFeedDetailDao.selectList(new LambdaQueryWrapper<PrdFeedDetail>()
                .eq(PrdFeedDetail::getMOBILLNO, sfcProplan.getMoBillNo())
                .eq(PrdFeedDetail::getTEMP, true));
        //获取车间信息
        List<SfcproplanDetail> sfcproplanDetailList = sfcproplanDetailDao.selectList(new LambdaQueryWrapper<SfcproplanDetail>()
                .eq(SfcproplanDetail::getBillNo, billNo));
        String departName = sfcproplanDetailList.get(0).getDepartName();
        //铸造车间26号7点后算作次月1号，
        //机加车间26号7:45后算作次月1号,1号还是1号，1-25号 7.45之前算作前一天，之后算作当天
        if (departName.contains("机加")){
            Date fdate = DateUtils.adjustDateJiJia(new Date());
            sfcProplan.setFDate(fdate);
        } else {
            Date fdate = DateUtils.adjustDateZhu(new Date());
            sfcProplan.setFDate(fdate);
        }

        Map<String,Object> data = new HashMap<>();
        data.put("data",sfcProplan);
        data.put("dataList",detailList);
        return data;
    }

    /**
     * 手机端模具领用详情
     * @param map
     * @param user_id
     * @return
     * @throws Exception
     */
    @Override
    public Map<String, Object> getPlanDetailMold(Map<String, Object> map, Long user_id) throws Exception {
        String billNo = VtuzxUtil.getString(map,"billNo");
        SfcProplan sfcProplan = sfcProplanpDao.selectOne(new LambdaQueryWrapper<SfcProplan>()
                .eq(SfcProplan::getBillNo,billNo));
        if(null == sfcProplan){
            throw new RuntimeException("单号错误请重试");
        }
        String moBillNo = sfcProplan.getMoBillNo();//订单号
        //查询用料清单中所需要的模具信息，模具分组是0601
        List<PpBom> ppBomList = ppBomDao.selectList(new LambdaQueryWrapper<PpBom>()
                .eq(PpBom::getFMOBILLNO, moBillNo)
                .like(PpBom::getFMATERIALNUMBER,"0601"));
        //查询当前所需要的在库的模具
        List<MoldMaterial> needMoldList = new ArrayList<>();
        if (!VtuzxUtil.isEmpty(ppBomList)){
            needMoldList = moldMaterialDao.selectList(new LambdaQueryWrapper<MoldMaterial>()
                    .eq(MoldMaterial::getMaterialNo,ppBomList.get(0).getFMATERIALNUMBER())
                    .eq(MoldMaterial::getStatus,0)//单据状态在库
                    .eq(MoldMaterial::getInspectStatus,2)//检查状态正常
                    .and(w -> w.isNull(MoldMaterial::getIsTemp).or().eq(MoldMaterial::getIsTemp,false)));
        }


        //查询模具信息
        List<MoldMaterial> moldMaterials = moldMaterialDao.selectList(new LambdaQueryWrapper<MoldMaterial>()
                .eq(MoldMaterial::getAssBillNo, billNo)
                .eq(MoldMaterial::getIsTemp,true));//查询是临时的数据


        Map<String,Object> data = new HashMap<>();
        data.put("data",sfcProplan);
        data.put("dataList",ppBomList);
        data.put("moldList",moldMaterials);
        data.put("needMoldList",needMoldList);//所需要的在库的模具
        return data;
    }

    /**
     * 手机端归还模具
     * @param map
     * @param user_id
     * @return
     * @throws Exception
     */
    @Override
    public Map<String, Object> getPlanDetailMoldReturn(Map<String, Object> map, Long user_id) throws Exception {
        String billNo = VtuzxUtil.getString(map,"billNo");
        SfcProplan sfcProplan = sfcProplanpDao.selectOne(new LambdaQueryWrapper<SfcProplan>()
                .eq(SfcProplan::getBillNo,billNo));
        if(null == sfcProplan){
            throw new RuntimeException("单号错误请重试");
        }

        //查询领用的模具信息
        List<MoldMaterial> moldMaterials = moldMaterialDao.selectList(new LambdaQueryWrapper<MoldMaterial>()
                .eq(MoldMaterial::getAssBillNo, billNo));//查询是临时的数据


        Map<String,Object> data = new HashMap<>();
        data.put("data",sfcProplan);
        data.put("moldList",moldMaterials);
        return data;
    }

    @Override
    public Map<String, Object> getPlanlistMoldStatus(Map<String, Object> map) throws Exception {
        int pageIndex = VtuzxUtil.getInt(map,"pageIndex");
        int pageSize = VtuzxUtil.getInt(map,"pageSize");
        String billNo = VtuzxUtil.getString(map,"billNo");//订单号
        List<SfcProplan> dataList = sfcProplanpDao.getPlanlistMoldStatus(pageSize,pageIndex * pageSize,billNo);
        Map<String,Object> data = new HashMap<>();
        data.put("dataList",dataList);
        return data;
    }

    /**
     * 根据托盘编号查询对应工单
     * @param map
     * @return
     * @throws Exception
     */
    @Override
    public Map<String, Object> getOperNoByTray(Long user_id, Map<String, Object> map) throws Exception {
        String trayNo = map.get("billNo").toString();
        Tray tray = trayDao.selectOne(new LambdaQueryWrapper<Tray>()
                .eq(Tray::getFBILLNO, trayNo));
        if (VtuzxUtil.isEmpty(tray)){
            throw new RuntimeException("托盘不存在");
        }
        //如果托盘已经绑定工单了，直接返回工单号即可
        if (!VtuzxUtil.isEmpty(tray.getFOPERPNO())){
            Map<String,Object> data = new HashMap<>();
            data.put("billNo",tray.getFOPERPNO());
            return data;
        }
        //通过托盘上的物料，在bom中查询父项物料编码，托盘上的物料为子项物料编码
        //获取到父项物料编码后再查询工序计划中物料为父项物料的订单
        String fmaterialnumber = tray.getFMATERIALNUMBER();
        String materialNoList;//父项物料编码,根据此编码查询工序计划单

        try {
            materialNoList = getFatherNo(user_id,fmaterialnumber);
        } catch (Exception e){
            throw new RuntimeException(e.getMessage());
        }
//        SfcProplan sfcProplan = sfcProplanpDao.selectOne(new LambdaQueryWrapper<SfcProplan>()
//                .eq(SfcProplan::getMaterialNo, materialNo)
//                .orderByDesc(SfcProplan::getDate)
//                .last("limit 1"));
//        if (VtuzxUtil.isEmpty(sfcProplan)){
//            throw new RuntimeException(String.format("没有物料%s,的工单",materialNo));
//        }

        Map<String,Object> data = new HashMap<>();
        data.put("billNo",materialNoList);
        return data;
    }

    @Override
    public Map<String, Object> getOperNoByTrayInStock(Long user_id, Map<String, Object> map) throws Exception {
        //先判断FOPERPNO(机加车间绑定的)有没有值，有的话，返回这个，
        // 在判断OPERNOSM有没有，都没有的话给提示
        String trayNo = map.get("billNo").toString();
        PrdInstock prdInstock = prdInstockDao.selectOne(new LambdaQueryWrapper<PrdInstock>()
                .eq(PrdInstock::getTRAYNO, trayNo));
        String fBillNo = prdInstock.getFBillNo();

        Map<String,Object> data = new HashMap<>();
        data.put("billNo",fBillNo);
        return data;

    }

    /**
     * 根据子项物料编码查询父项物料
     * @param user_id
     * @param materialNo
     * @return
     */
    private String getFatherNo(Long user_id,String materialNo) throws Exception{
        VtuzxKingdeeCloudClient client = null;
        try {
            client = vtuzxKingdeeService.loginKingdeeByUser(user_id);
        } catch (Exception e){
            throw new RuntimeException("金蝶账号密码错误，请维护");
        }
        List<String> getFatherNoList = new ArrayList<>();
        //查询物料是够启用批号
        List<VtuzxMap> materialQuery = vtuzxKingdeeService.query(client, "ENG_BOM", new VtuzxArrayList<>(
                        "FMATERIALID.fnumber",//父项物料编码
                        "FMATERIALID.FSPECIFICATION",//父项规格(件号)
                        "FITEMMODEL"//规格型号(件号)
                ),
                String.format("FMATERIALIDCHILD.fnumber = '%s'", materialNo), null, 0, 0);
        if(!VtuzxUtil.isEmpty(materialQuery)){
            for (VtuzxMap fatherMap : materialQuery){
                String fatherNo = VtuzxUtil.getString(fatherMap,"FMATERIALID.FSPECIFICATION");
                if(!getFatherNoList.contains(fatherNo)){
                    getFatherNoList.add(fatherNo);
                }
            }
//            fatherNo = VtuzxUtil.getString(materialQuery.get(0),"FMATERIALID.FSPECIFICATION");
        } else {
            throw new RuntimeException(String.format("子项物料:%s,没有bom,无法获取到订单",materialNo));
        }
        String result = String.join(",", getFatherNoList);
        return result;
    }


    //"查询工序计划明细(手机端领料详情)"
    @Override
    public Map<String, Object> getPlanDetail(Map<String, Object> map,Long user_id) {
        String billNo = map.get("billNo").toString();
        SfcProplan sfcProplan = sfcProplanpDao.selectOne(new LambdaQueryWrapper<SfcProplan>()
                .eq(SfcProplan::getBillNo,billNo));
        if(null == sfcProplan){
            throw new RuntimeException("单号错误请重试");
        }
        //详情数据展示领料中的临时数据信息
        List<PickDetail> detailList = pickDetailDao.selectList(new LambdaQueryWrapper<PickDetail>()
                .eq(PickDetail::getMOBILLNO, sfcProplan.getMoBillNo())
                .eq(PickDetail::getTEMP, true));
        //获取车间信息
        List<SfcproplanDetail> sfcproplanDetailList = sfcproplanDetailDao.selectList(new LambdaQueryWrapper<SfcproplanDetail>()
                .eq(SfcproplanDetail::getBillNo, billNo));
        String departName = sfcproplanDetailList.get(0).getDepartName();
        //铸造车间26号7点后算作次月1号，
        //机加车间26号7:45后算作次月1号,25号之前7点45之前算作前一天，7:45之后算作后一天
        if (departName.contains("机加")){
            Date fdate = DateUtils.adjustDateJiJia(new Date());
            sfcProplan.setFDate(fdate);
        } else {
            Date fdate = DateUtils.adjustDateZhu(new Date());
            sfcProplan.setFDate(fdate);
        }


        Map<String,Object> data = new HashMap<>();
        data.put("data",sfcProplan);
        data.put("dataList",detailList);
//        data.put("ppBomList",ppBomList);
        return data;
    }

}
